package kr.saeildamil.androidstudy.ch09;

import kr.saeildamil.androiddforstudy.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.widget.TextView;

public class OptionMenu extends Activity {
	TextView tv;
	final int JJANG = 1;
	final int JJAM = 2;
	final int WOO = 3;
	final int MAN = 4;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		tv = new TextView(this);
		tv.setText("Press ths Menu");
		setContentView(tv);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
			super.onCreateOptionsMenu(menu);
			
			MenuItem item = menu.add(0, JJANG, 0, "짜장");
			item.setIcon(R.drawable.ic_launcher);
			
			menu.add(0, JJAM, 0, "짬뽕").setIcon(R.drawable.ic_launcher);
			
			SubMenu etc = menu.addSubMenu("기타");
			etc.add(0, WOO, 0, "우동");
			etc.add(0, MAN, 0, "만두");
			
			return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case JJANG:
			tv.setText("짜장은 달콤해");
			break;
		case JJAM:
			tv.setText("짬뽕은 매워");
			break;
		case WOO:
			tv.setText("우동은 시원해");
			break;
		case MAN:
			tv.setText("만두는 공짜");
			break;
		}
		return false;
		
	}
	
}
